function showToast(title) {
    wx.showToast({
        title: title,
        icon: 'none'
    })
}
// 请求函数
export function request(method, data, url, isForm,header) {

    // 合并 header
    const combinedHeader = {
        ...header,
         'content-type': isForm ? 'application/x-www-form-urlencoded' : 'application/json'
     };

    return new Promise((resolve, reject) => {
        wx.request({
            url: url,
            method: method,
            data: data,
            timeout: 5000,
            header: combinedHeader,
            success(res) {
                if (res.data.code === '0000' || res.data.code === 1 || res.data.code === 0) {
                    resolve(res.data);
                } else {
                    showToast(res.data.msg)
                }
            },
            fail(res) {
                showToast('请求出错')
            }
        })
    })
}